//
//  QJWebViewController.m
//  QJReceiveGuests
//
//  Created by hle1 on 2020/11/9.
//

#import "QJWebViewController.h"

@interface QJWebViewController ()
<APIWebViewDelegate, APIModuleMethodDelegate, APIScriptMessageDelegate>

@end

@implementation QJWebViewController

#pragma mark - LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    
}

#pragma mark - Public

#pragma mark - Private


/// 初始化视图
- (void)subViews {

}

/// 初始化导航
- (void)initNavigation {
    
}

/// 初始化数据
- (void)initData {
    APIManager *manager = [APIManager sharedManager];
    manager.webViewDelegate = self;
    manager.moduleMethodDelegate = self;
    manager.scriptMessageDelegate = self;
    
    
}

/// hook方法
- (void)hookMethod{
    
}

#pragma mark - Event

#pragma mark - Delegate
// 在h5页面调用api.accessNative方法后会触发代理方法
- (void)webView:(APIWebView *)webView didReceiveScriptMessage:(APIScriptMessage *)scriptMessage {
    if ([scriptMessage.name isEqual:@"weiLogin"]) {
        NSString *msg = [NSString stringWithFormat:@"收到来自Html5的操作请求，访问的名称标识为%@，传入的参数为:%@", scriptMessage.name, scriptMessage.userInfo];
        NSLog(@"%@",msg);
        [scriptMessage callbackWithRet:@{@"para1":@"原生参数1",
                                         @"para2":@"原生参数2"
        } err:nil delete:YES];
    }
}
#pragma mark - NetWorkRequest

#pragma mark - Getting/Setting

@end
